package com.example.crawler.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

/**
 * org.hebeigaokao.common.utils
 *
 * @author 白雨浓
 * date: 2017/10/4 0:36
 * content:URL工具
 */
public class UrlUtil {
    private final static String ENCODE = "UTF-8";

    /**
     * URL 解码
     */
    public static String getURLDecoderString(String str) throws UnsupportedEncodingException {
        if (str == null)
            return "";
        return URLDecoder.decode(str, ENCODE);
    }

    /**
     * URL 转码
     */
    public static String getURLEncoderString(String str) throws UnsupportedEncodingException {
        if (str == null)
            return "";
        return URLEncoder.encode(str, ENCODE);
    }
}